<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /* 创建字符串 */
        var str1 = "我爱JavaScript"
        var str2 = ''
        var str3 = new String()
        var str4 = new String("Hello World")

        console.log(str1);
        console.log(str2);
        console.log(str3);
        console.log(str4);

        /* 长度是只读的,不能修改 */
        console.log("字符串的长度",str1.length);

        /* 修改数组的长度 */
        // str1.length = 1;
        // console.log(str1);

        //获取字符串的第一个元素
        str1[0] = "你"
        console.log(str1);

        for(var i = 0 ; i < str1.length ; i++){
            console.log(str1[i]);
        }
    </script>
</body>
</html>